package org.geektimes.reactive.streams.simple;

import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;

/**
 * @FileName: DefaultSubscriberWarpper
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2021/3/30 - 下午11:11
 */
public class DefaultSubscriberWrapper<T> implements Subscriber<T> {

    private final Subscriber subscriber;

    private final DefaultSubscription subscription;

    public DefaultSubscriberWrapper(Subscriber subscriber, DefaultSubscription subscription) {
        this.subscriber = subscriber;
        this.subscription = subscription;
    }

    @Override
    public void onSubscribe(Subscription s) {
        subscriber.onSubscribe(s);
    }

    @Override
    public void onNext(T t) {
        subscriber.onNext(t);
    }

    @Override
    public void onError(Throwable t) {
        subscriber.onError(t);
    }

    @Override
    public void onComplete() {
        subscriber.onComplete();
    }

    public Subscriber<T> getSubscriber() {
        return subscriber;
    }

    public DefaultSubscription getSubscription() {
        return subscription;
    }
}
